Migrating Content from Music Object 1.x to 2.x

Versions 2.x (and later) of the Music Object API offer significant benefits to authors over the earlier 1.x versions, making available new features in the Beatnik Player and offering the ability to author for the Beatnik ActiveX Control for Microsoft Internet Explorer using the very same authoring that will work for the Beatnik Plug-in in Netscape Navigator. New methods have been added to the API, and code changes in the API have improved the performance in certain areas.

NOTES
  • For the purposes of this document, the term "Beatnik Player" refers to both the Beatnik Plug-in for Netscape Navigator and the Beatnik ActiveX Control for Internet Explorer.
  • At the time of this writing, the Beatnik ActiveX Control has not yet been released.

If you are still using version 1.x, it is high time you switched! If you are unsure which version you are currently using, consult Which Music Object Version Are You Using?. To update to the latest version, follow the simple instructions below:

1. Make Backups

Create a backup of the local versions of any Web sites you wish to update BEFORE you make any of the following changes. This is a wise safety measure.

2. Download the Latest Music Object

Download the new "music-object.js" file by right-clicking (click-and-hold for Mac users) on the link below and selecting the 'Save Link As...' or 'Save Target As...' option from the pop-up menu. Save the file to your local hard drive.

music-object.js

If this does not work or you do not see a 'Save Link As...' or 'Save Target As...' option in the pop-up, you can also obtain the new "music-object.js" file if you download the latest version of the Beatnik Music Object Documentation. Once you have downloaded and de-archived the documentation, you can find the "music-object.js" file by following these steps...

  1. Open up the documentation's main folder.
  2. Then, from inside the documentation's main folder, open up the folder called "web-authoring".
  3. Inside this folder, you will see a folder called "javascript". This is where the "music-object.js" file is located.
  4. Copy the file from this location.

     IMPORTANT : Be sure NOT to move the "music-object.js" file outside of the "javascript" folder, as this would cause the documentation to not function correctly.

3. Replace Your Existing Music Object

Now that you have the latest "music-object.js" file, simply replace the existing "music-object.js" file you are using in any and all Web sites that you have authored with interactive Beatnik content.

4. Modify Your Code

Creating Music Object Instances

With versions 2.x and later, it is no longer necessary to assign the result of the new operator to a variable. For example, in version 1.x it was necessary to create a Music Object instance with the following assignment syntax:

myMusicObject = new musicObject ('myMusicObject');

It is now only necessary to call the Music Object constructor with the name of the object instance you'd like to create. A variable is then automatically created and can be referenced as though you'd created it in an assignment. For example, the code above would now become just:

new musicObject ('myMusicObject');

This has the advantage of simplifying your code a little but also eliminating the need to specify the exact same object instance name twice - once in the assignment, and once as a string passed to the Music Object constructor. This reduces the risks of code not working because of these names not being identical - as a result of an innocent typo, for example.

Using the magicEmbed Method

For interactive authoring, the way that one embeds Beatnik Players into an HTML page is slightly different in Music Object versions 2.x and later. One no longer places explicit EMBED tags into the HTML, but now will use the Music Object's magicEmbed method to place an instance in a page. To ease the transition into this new authoring approach, it was decided that the magicEmbed method would be called with a single string parameter, representing the EMBED tag as it would otherwise appear in the HTML. The magicEmbed method then processes the string and writes out an EMBED tag or OBJECT tag into the HTML document, depending on whether the user is browsing with Navigator or Internet Explorer. So, essentially, you just cut and paste your old EMBED tags and place them between quotes in a magicEmbed method call.

There are some other benefits to the new approach, as well. Take a look at the example below to compare the old approach with the new. In the example we have a Music Object instance named "myMusicObject" and we wish to embed a Beatnik Player in the HTML page to be associated with that instance. The old HTML EMBED tag would look as follows:

<EMBED
   SRC="my-music-file.rmf"
   TYPE="audio/rmf"
   PLUGINSPAGE="http://www.beatnik.com/to/?player"
   NAME="myMusicObjectPlugin"
   WIDTH=2
   HEIGHT=2
   HIDDEN
   AUTOSTART=FALSE
   ONREADY="myMusicObject.setReady ()"
>

Because the magicEmbed method automatically fills in appropriate values for the TYPE, PLUGINSPAGE, NAME, and ONREADY attributes, it is not necessary to have these in the EMBED tag one places in the magicEmbed method call. One can simply delete these attributes. It is also not necessary to specify the "<EMBED " text that opens the EMBED tag, nor is it necessary to use ">" to close the EMBED tag. So, in the new approach, the code would look as follows:

<SCRIPT LANGUAGE=JavaScript><!-- //

myMusicObject.magicEmbed ('SRC="my-music-file.rmf" WIDTH=2 HEIGHT=2 HIDDEN AUTOSTART=FALSE');

// --></SCRIPT>

Key Benefits to the New Syntax

See also Music Object Reference, magicEmbed.

5. Test Your Content

Check your Web site pages locally to ensure that all your content is still working. If possible, use several browser versions in your testing. Do not delete the backup(s) that you made in step 1 until you have uploaded the changes to the online version of your Web site and verified that all your content works online as well. There are some authoring issues that only impact content when it is being served from a Web server. Even if you have tested your content online and are confident everything is peachy, you may still wish to keep the backups hanging around for a week or so, just in case. Sometimes it is not possible to test all possibilities and you may receive reports from Web site visitors saying that things are suddenly amiss with your content. Always play it safe with your Web content.